#include "as2_t4.h"
#include <sys/times.h>
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#define AMOUNT 100000

int main(int argc, char *argv[]) {
  task_t *tasks[AMOUNT];
  task_t *tasks2[AMOUNT];
  struct tms before;
  struct tms after;
  int i;

  
  times(&before);

  for(i = 0; i < AMOUNT; i++) {
    tasks[i] = task_alloc();
  }
  times(&after);


  printf("Time to tasks_alloc is %ld clock ticks\n", (after.tms_utime - before.tms_utime));
  times(&before);
  for(i = 0; i < AMOUNT; i++) {
    tasks2[i] = (task_t*) malloc(sizeof(task_t));
  }
  times(&after);

  printf("Time to malloc is %ld clock ticks\n", (after.tms_utime - before.tms_utime));
  times(&before);

  for(i = 0; i < AMOUNT; i++) {
    task_free(tasks[i]);
  }
  times(&after);

  printf("Time to tasks_free is %ld clock ticks\n", (after.tms_utime - before.tms_utime));
  times(&before);

  for(i = 0; i < AMOUNT; i++) {
    free(tasks2[i]);
  }
  times(&after);

  printf("Time to free is %ld clock ticks\n", (after.tms_utime - before.tms_utime));
  
  return 0;
}
